package com.tianji.remark.task;

import com.tianji.remark.service.LikedRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
@RequiredArgsConstructor
public class LikedTimesCheckTask {
    private static final List<String> BIZ_TYPES = List.of("QA", "NOTE");
    private static final int MAX_BIZ_SIZE = 30;
    private final LikedRecordService likedRecordService;

    @Scheduled(cron = "*/20 * * * * ?") //每隔20秒执行一次
    public void checkLikedTimes(){
        for(String item:BIZ_TYPES){
            likedRecordService.readLikedTimesAndSendMessage(item,MAX_BIZ_SIZE);
        }
    }
}
